package yang.yu.sunny.infra.persistence;

import org.aspectj.lang.JoinPoint;
import yang.yu.sunny.infra.persistence.product.AbstractProductMapper;
import yang.yu.sunny.infra.persistence.sales.AbstractSalesMapper;

/**
 * Created by yyang on 16/3/30.
 */
public class DataSourceAdvice {

    public void before(JoinPoint jp) {
        if (jp.getTarget() instanceof AbstractSalesMapper) {
            DataSourceHolder.set(DataSources.SALES);
            return;
        }
        if (jp.getTarget() instanceof AbstractProductMapper) {
            DataSourceHolder.set(DataSources.PRODUCT);
            return;
        }
    }
}
